import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanLifeTest {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext
                context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        ClassPathXmlApplicationContext
                context2 =
                new ClassPathXmlApplicationContext("spring-config.xml");
        BeanLifeComponent beanLifeComponent =
                context.getBean("mybean",BeanLifeComponent.class);
        BeanLifeComponent beanLifeComponent2 =
                context.getBean("mybean",BeanLifeComponent.class);
        beanLifeComponent.use();
        beanLifeComponent2.use();
        System.out.println(beanLifeComponent == beanLifeComponent2);
        // 关闭容器
        context.close();
    }
}
